import Vue from 'vue'
import Vuex from 'vuex'
import createLogger from 'vuex/dist/logger'
import createPersistedState from "vuex-persistedstate";

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        collectlist: []
    },
    getters: {
    },
    mutations: {
        collect(state, payload) { //收藏一个店铺
            state.collectlist.push(payload);

        },
        cancel_collect(state, payload) { //取消收藏一个店铺
            var index = state.collectlist.findIndex((item) => {
                return item.mtWmPoiId == payload.mtWmPoiId;
            })
            if (index != -1) {
                state.collectlist.splice(index, 1);
            }
        },
    },
    actions: {
    },
    modules: {
    },
    plugins: [createLogger(), createPersistedState()]
})
